﻿function StoryPartial(self) {
    self.openLink = ko.computed(function () {
        return "/Story/Details/" + self.id();
    });
}

function CharacterPartial(self) {
    self.fullname = ko.computed(function () {
        return self.forename() + " " + self.surname();
    });

    self.fullnameWithAbbrev = ko.computed(function () {
        return self.fullname() + " (" + self.abbreviation() + ")";
    });

    self.dateOfBirthFormatted = ko.computed(function () {
        var d = new Date(self.dateOfBirth() + "z");
        return d.getDate() + "/" + d.getMonth() + "/" + d.getFullYear();
    });

    self.dateOfDeathFormatted = ko.computed(function () {
        var d = new Date(self.dateOfDeath() + "z");
        return d.getDate() + "/" + d.getMonth() + "/" + d.getFullYear();
    });

    self.genderFormatted = ko.computed(function () {
        switch (self.gender()) {
            case 0:
                return "male";
            case 1:
                return "female";
            default:
                return "";
        }
    });
}